<template>
	<view class="main">
		<view class="fangwurenzheng">
			<view class="fanhuijiemian">
				<view class="fanhui" @click="fanhui">
					<image class="fanh-img" src="../../static/images/index/向左箭头(1).png" mode=""></image>
					<view class="fanh">返回</view>
				</view>
				<view class="fanwu">房屋认证</view>
			</view>
		</view>
		<!-- 房屋信息 -->
		<view class="xinxi">房屋信息</view>
		<view class="xiaoquda">
			<!-- 小区 -->
			<view class="uni-list-cell">
				<view class="uni-list-cell-left">小区</view>
				<view class="uni-list-cell-db">
					<picker @change="bindPickerChange" :value="index" :range="buildings">
						<view class="uni-input">{{index !==""?buildings[index]:'请选择小区'}}
							<image class="you-img" src="../../static/images/index/右.png" mode=""></image>
						</view>
					</picker>
				</view>
			</view>
			
			<!-- 楼栋房号 -->
			<view class="uni-list-cell">
				<view class="uni-list-cell-left">
					楼栋房号
				</view>
				<view class="uni-list-cell-db">
					<view class="" @click="selectbuilding">
						请选择楼栋信息
						<image class="you-img" src="../../static/images/index/右.png" mode=""></image>
					</view>
				</view>
			</view>
			<!-- 住户类型 -->
			<view class="uni-list-cell" style="border-bottom: none;">
				<view class="uni-list-cell-left">
					住户类型
				</view>
				<view class="uni-list-cell-db">
					<picker @change="bindPickerChanges" :value="indexs" :range="buildingb">
						<view class="uni-input">{{indexs !==""?buildingb[indexs]:'请选择住户类型'}}
							<image class="you-img" src="../../static/images/index/右.png" mode=""></image>
						</view>
					</picker>	
				</view>
			</view>
		</view>
		
		<!-- 个人信息 -->
		<view class="xinxi">个人信息</view>
		<view class="geirenxixi">
			<view class="xmsjh">
				<view class="xingming">姓名</view>
				<view class="xingmingkuang">
					<input type="text" placeholder="请填写姓名">
				</view>
			</view>
			<!-- 联系电话 -->
			<view class="xmsjh" style="border-bottom: none;">
				<view class="xingming">联系电话</view>
				<view class="xingmingkuang" style="width: 270rpx;">
					<input type="text" placeholder="18366090134">
				</view>
			</view>
		</view>
		
		<view class="tijiao">提交</view>
		
	</view>
</template>

<script>
	import Index from '@/apis/index.js'
	import {mapMutations} from 'vuex'
	export default {
		data() {
			return {
				buildings:[],
				index:'',
				array:'',
				buildingb:[],
				indexs:''
			}
		},
		onLoad(){
			this.geyBuildingData()
			this.geyBuildingbody()
		},
		methods:{
			fanhui(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
			...mapMutations(['setBuildingData','setBuildingbody']),
			async geyBuildingData(){
				let res = await Index.userbuildinglist()
				if(res.errCode==10000){
					//存入到vuex 内
					this.setBuildingData(res.data.list)
					//把小区的数据整理到buildings
					this.buildings = res.data.list.map((item)=>item.name)
				}
			},
			async geyBuildingbody(){
				let res = await Index.userhouseslx()
				console.log(res);
				if(res.errCode==10000){
					//存入到vuex 内
					this.setBuildingbody(res.data.list)
					//把小区的数据整理到buildingb
					this.buildingb= res.data.list.map((item)=>item.name)
				}
			},
			bindPickerChange(e){
				this.index = e.detail.value
			},
			bindPickerChanges(e){
				this.indexs = e.detail.value
			},
			selectbuilding(){
				if(this.index!==""){
					uni.navigateTo({
						url:'/pages/HousePage/HousePage2?index='+this.index
					})
				}else{
					this.$message.error('请选择小区')
					return
				}
				
			}
		}
	}
</script>

<style>
@import url('../../static/css/housePage/housepage.css');
</style>
